﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BasicConsoleIO
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("***** Basic Console IO *****");
            Console.WriteLine();

            GetUserData();
            Console.WriteLine();

            FormatNumbericalData();
            Console.WriteLine();

            Console.ReadLine();
        }

        /// <summary>
        /// 基本输入输出
        /// </summary>
        private static void GetUserData()
        {
            //获取姓名年龄
            Console.Write("Please enter your name:");
            string userName = Console.ReadLine();
            Console.Write("Please enter your age:");
            string userAge = Console.ReadLine();

            //改变回复的颜色
            ConsoleColor prevColor = Console.ForegroundColor;
            Console.ForegroundColor = ConsoleColor.Yellow;

            //回复控制台
            Console.WriteLine("Hello {0}! You are {1} years old.",
                userName, userAge);

            Console.ForegroundColor = prevColor;

        }

        /// <summary>
        /// 格式化数据
        /// </summary>
        private static void FormatNumbericalData()
        {
            Console.WriteLine("The Value of 99999 in various formats:");
            Console.WriteLine("c format: {0:c}", 99999);
            Console.WriteLine("d9 format: {0:d9}", 99999);
            Console.WriteLine("f3 format: {0:f3}", 99999);
            Console.WriteLine("n format: {0:n}", 99999);

            Console.WriteLine("E format: {0:E}", 99999);
            Console.WriteLine("e format: {0:e}", 99999);
            Console.WriteLine("X format: {0:X}", 99999);
            Console.WriteLine("x format: {0:x}", 99999);
        }
    }
}
